home *** CD-ROM | disk | FTP | other *** search
/ MacWarehouse Macintosh Games / MacWarehouse Macintosh Games.iso / AMBER demo / AMBER-Journeys Beyond™ Patch 1c / 00104_generic domain rules.ls < prev    next >
Encoding:
Text File  |  1997-02-19  |  12.6 KB  |  455 lines

  1. on cursorOff
  2.   global colorcrsr, YugoCursors, gCursorSwitch
  3.   if objectp(colorcrsr) then
  4.     colorcrsr(mGetSetCursor, getProp(YugoCursors, #noCursor))
  5.     set gCursorSwitch to #off
  6.   else
  7.     cursor(200)
  8.     set gCursorSwitch to #off
  9.   end if
  10. end
  11.  
  12. on cursorOn
  13.   global colorcrsr, YugoCursors, thisCursor, gCursorSwitch
  14.   if gCursorSwitch = #off then
  15.     if objectp(colorcrsr) then
  16.       colorcrsr(mGetSetCursor, getProp(YugoCursors, thisCursor))
  17.     else
  18.       castCursor(getProp(YugoCursors, thisCursor))
  19.     end if
  20.     set gCursorSwitch to #on
  21.   end if
  22. end
  23.  
  24. on castCursor cursorID
  25.   set myCursorOffset to 1400
  26.   if integerp(cursorID) then
  27.     set whichCursor to cursorID - 6000
  28.   else
  29.     put "castCursor(): wow, a cursor label: "
  30.     put cursorID
  31.     exit
  32.   end if
  33.   set cMask to myCursorOffset + (whichCursor * 2)
  34.   cursor([cMask - 1, cMask])
  35. end
  36.  
  37. on killVideo
  38.   global lastScoreSprite
  39.   set vidSprite to 44
  40.   set the movieRate of sprite vidSprite to 0
  41.   set the locV of sprite vidSprite to -500
  42.   updateStage()
  43.   set the castNum of sprite vidSprite to 7
  44.   puppetSprite(vidSprite, 0)
  45. end
  46.  
  47. on pushVideo start_time, stop_time
  48.   set vidSprite to 44
  49.   set the movieTime of sprite 44 to 0
  50.   updateStage()
  51.   set the movieRate of sprite 44 to 1
  52.   if the paramCount > 0 then
  53.     set the startTime of sprite 44 to start_time
  54.     set the stopTime of sprite 44 to stop_time
  55.     set the movieTime of sprite 44 to start_time
  56.   end if
  57.   repeat while the movieRate of sprite 44 <> 1
  58.     updateStage()
  59.   end repeat
  60. end
  61.  
  62. on setCurrentLocation suggestion
  63.   return "Use the goTo() function instead.."
  64. end
  65.  
  66. on goTo destination, transition
  67.   global oPuppeteer, oStoryteller, builderWindow, gPreloading, gScanFinish, colorcrsr, YugoCursors, thisCursor, gCursorSwitch, gPeekAlertEnabled, domainIsReady
  68.   report(">starting 'goTo()'  (" & the timer & " ticks after mouseDown)")
  69.   if objectp(colorcrsr) then
  70.     colorcrsr(mGetSetCursor, getProp(YugoCursors, #noCursor))
  71.   else
  72.     cursor(200)
  73.   end if
  74.   set gCursorSwitch to #off
  75.   if (destination = #destination) or (transition = #transition) then
  76.     exit
  77.   end if
  78.   report(">cursorOff done (" & the timer & " ticks)")
  79.   setAt(getProp(the lsStateData of oStoryteller, #previousLocation), 1, getAt(getProp(the lsStateData of oStoryteller, #currentLocation), 1))
  80.   setAt(getProp(the lsStateData of oStoryteller, #currentLocation), 1, destination)
  81.   if the castNum of sprite 44 <> 7 then
  82.     killVideo()
  83.     moveMovies(oPuppeteer)
  84.   end if
  85.   setTransition(oPuppeteer, transition)
  86.   report(">'setTransition()' done (" & the timer & " ticks)")
  87.   moveToLocation(oPuppeteer)
  88.   report(">'moveToLocation()' done (" & the timer & " ticks)")
  89.   if getPos(the windowList, builderWindow) then
  90.     tell builderWindow
  91.       refreshCast()
  92.       refreshHotspots()
  93.     end tell
  94.   end if
  95.   if gPreloading = 1 then
  96.     preloadLocations()
  97.     report(">preLoadLocations done (" & the timer & " ticks)")
  98.   else
  99.     report(">preLoadLocations skipped (" & the timer & " ticks)")
  100.   end if
  101.   report(" Available memory: " & the freeBytes / 1024 & " K (incl. " & the freeBlock / 1024 & " K block)")
  102.   report("   :")
  103.   set lsMoveCounter to getProp(the lsStateData of oStoryteller, #moveCount)
  104.   set oldCount to getAt(lsMoveCounter, 1)
  105.   setAt(lsMoveCounter, 1, oldCount + 1)
  106.   if domainIsReady then
  107.     if the castNum of sprite 44 <> 7 then
  108.       killSongs(#PConly)
  109.     else
  110.       playaSong()
  111.     end if
  112.   end if
  113.   return #OK
  114. end
  115.  
  116. on goBack
  117.   global oStoryteller
  118.   goTo(getState(oStoryteller, #previousLocation), #backOff)
  119. end
  120.  
  121. on idle
  122.   global lastCursor, thisCursor, cursorOffset, castCursorList, maxCursor, oStoryteller, oPuppeteer, gCurrentHotspot, gItemInUse, domainIsReady, gPreloading, gStopTransitions, g16bit, gTransQuality, gFreezeInventory, gSoundPath, gOriginPoint, gMenuBottomY, gGustReady, gGammaLevel, gDeferredTransit
  123.   if gDeferredTransit = #none then
  124.     if domainIsReady then
  125.       cursorOn()
  126.       set thisCursor to #pointer
  127.       set gCurrentHotspot to #none
  128.       if the mouseV < gMenuBottomY then
  129.         if the number of menus = 0 then
  130.           installMenu(the number of cast "Amber menus")
  131.           if gTransQuality = #none then
  132.             set the checkMark of menuItem 1 of menu 3 to 1
  133.           end if
  134.           if gTransQuality = #Better then
  135.             set the checkMark of menuItem 2 of menu 3 to 1
  136.           end if
  137.           if gTransQuality = #Best then
  138.             set the checkMark of menuItem 3 of menu 3 to 1
  139.           end if
  140.           set the checkMark of menuItem (8 - the soundLevel) of menu 2 to 1
  141.           if gGammaLevel <> "unknown" then
  142.             set the checkMark of menuItem (8 - gGammaLevel) of menu 4 to 1
  143.           end if
  144.           set thisCursor to #pointer
  145.         end if
  146.       else
  147.         installMenu(0)
  148.       end if
  149.       set mouseLoc to point(the mouseH, the mouseV) - gOriginPoint
  150.       repeat with i in the lsLiveHotspots of oPuppeteer
  151.         if inside(mouseLoc, getAt(i, 2)) then
  152.           set myCursor to getAt(i, 1)
  153.           if myCursor = #itemInUse then
  154.             set thisCursor to getState(oStoryteller, #itemInUse)
  155.           else
  156.             set thisCursor to myCursor
  157.           end if
  158.           set gCurrentHotspot to i
  159.           exit repeat
  160.         end if
  161.       end repeat
  162.       prodVLoops()
  163.       if thisCursor <> lastCursor then
  164.         cursorDance(value(lastCursor & "To" & thisCursor))
  165.         set lastCursor to thisCursor
  166.       end if
  167.     end if
  168.     if domainIsReady and gGustReady then
  169.       gust()
  170.     end if
  171.   else
  172.     do(gDeferredTransit)
  173.     if gDeferredTransit contains "waiting" then
  174.       if domainIsReady = 1 then
  175.         if getState(oStoryteller, #currentDomain) = the last word in gDeferredTransit then
  176.           set gDeferredTransit to #none
  177.         end if
  178.       end if
  179.     end if
  180.   end if
  181. end
  182.  
  183. on cursorDance cursorList
  184.   global colorcrsr, thisCursor, YugoCursors, gCPU
  185.   if gCPU <> #PC then
  186.     if not objectp(colorcrsr) then
  187.       cursor(-1)
  188.       set colorcrsr to ColorCursor(mnew)
  189.     end if
  190.   end if
  191.   if not listp(cursorList) then
  192.     if objectp(colorcrsr) then
  193.       colorcrsr(mGetSetCursor, getProp(YugoCursors, thisCursor))
  194.     else
  195.       castCursor(getProp(YugoCursors, thisCursor))
  196.     end if
  197.     exit
  198.   end if
  199.   set flipBook to cursorList
  200.   if objectp(colorcrsr) then
  201.     repeat with flipper = 1 to count(flipBook)
  202.       startTimer()
  203.       colorcrsr(mGetSetCursor, getAt(flipBook, flipper))
  204.       repeat while 2 > the timer
  205.         nothing()
  206.       end repeat
  207.     end repeat
  208.   else
  209.     repeat with flipper = 1 to count(flipBook)
  210.       startTimer()
  211.       castCursor(getAt(flipBook, flipper))
  212.       repeat while 2 > the timer
  213.         nothing()
  214.       end repeat
  215.     end repeat
  216.   end if
  217. end
  218.  
  219. on inState stateVar, whichItem
  220.   global oStoryteller
  221.   set statelist to getProp(the lsStateData of oStoryteller, stateVar)
  222.   return getPos(statelist, whichItem)
  223. end
  224.  
  225. on trimState stateVar, whichItem
  226.   global oStoryteller
  227.   set statelist to getProp(the lsStateData of oStoryteller, stateVar)
  228.   set myPos to getPos(statelist, whichItem)
  229.   if myPos then
  230.     deleteAt(statelist, myPos)
  231.   end if
  232. end
  233.  
  234. on addState stateVar, whichItem
  235.   global oStoryteller
  236.   set statelist to getProp(the lsStateData of oStoryteller, stateVar)
  237.   set myPos to getPos(statelist, whichItem)
  238.   if not myPos then
  239.     append(statelist, whichItem)
  240.   end if
  241. end
  242.  
  243. on patchPalette
  244.   global oFixPal
  245.   oFixPal(mPatchIt)
  246. end
  247.  
  248. on forcePalette palName
  249.   global oPuppeteer, gCurrentPalette
  250.   puppetPalette(palName, 60)
  251.   set gCurrentPalette to #changeMe
  252.   patchPalette()
  253. end
  254.  
  255. on loadMultiFrames whichOnes
  256.   global oPuppeteer
  257.   set theFrames to getaProp(the lsMultiFrames of oPuppeteer, whichOnes)
  258.   if listp(theFrames) then
  259.     repeat with i in theFrames
  260.       preLoadCast(i)
  261.     end repeat
  262.   else
  263.     alert("Hey! There's no such list in lsMultiframes!")
  264.   end if
  265. end
  266.  
  267. on purgeMultiframes whichOnes
  268.   global oPuppeteer
  269.   set theFrames to getaProp(the lsMultiFrames of oPuppeteer, whichOnes)
  270.   if listp(theFrames) then
  271.     repeat with i in theFrames
  272.       unLoadCast(i)
  273.     end repeat
  274.   else
  275.     alert("Hey! There's no such list in lsMultiframes!")
  276.   end if
  277. end
  278.  
  279. on disablePeekAlert
  280.   nothing()
  281. end
  282.  
  283. on enablePeekAlert
  284.   nothing()
  285. end
  286.  
  287. on gammaFade upOrDown, howFast
  288.   global gCPU
  289.   if gCPU = #PC then
  290.     exit
  291.   end if
  292.   set speedCodes to [#glacial: "4", #slow: "18", #fast: "36", #instant: "100"]
  293.   set mySpeed to getaProp(speedCodes, howFast)
  294.   if voidp(mySpeed) then
  295.     set mySpeed to getProp(speedCodes, #fast)
  296.   end if
  297.   if upOrDown = #down then
  298.     MonitorFade("down", mySpeed)
  299.   else
  300.     updateStage()
  301.     MonitorFade("up", mySpeed)
  302.   end if
  303. end
  304.  
  305. on setColor howManybits
  306.   set the colorDepth to howManybits
  307.   if the colorDepth <> howManybits then
  308.     if howManybits = 16 then
  309.       set the colorDepth to 32
  310.     else
  311.       put "Sorry, Director sez the colorDepth is " & the colorDepth & " bits.."
  312.     end if
  313.   else
  314.   end if
  315. end
  316.  
  317. on fadeToMontage whichNumber
  318.   global oStoryteller, oPuppeteer
  319.   setState(oStoryteller, #showMontage, whichNumber)
  320.   setTransition(oPuppeteer, #fadeIn)
  321.   updateDisplay(oPuppeteer)
  322. end
  323.  
  324. on fadeOutTransit
  325.   repeat with fadeFactor = 30.0 down to 0.0
  326.     repeat with i = 1 to 4
  327.       set the volume of sound i to float(the volume of sound i) * (fadeFactor / 30.0)
  328.     end repeat
  329.     wait(8)
  330.     updateStage()
  331.   end repeat
  332. end
  333.  
  334. on playaSong
  335.   global oStoryteller, gSoundsSuspended, gLastCarolStart
  336.   if gSoundsSuspended then
  337.     exit
  338.   end if
  339.   if getState(oStoryteller, #carolsEnabled) = 0 then
  340.     exit
  341.   end if
  342.   if voidp(gLastCarolStart) then
  343.     set gLastCarolStart to 0
  344.   end if
  345.   if (the ticks - 12600) < gLastCarolStart then
  346.     exit
  347.   end if
  348.   set lsCarols to getProp(the lsStateData of oStoryteller, #windSongs)
  349.   set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
  350.   repeat with whichSound in lsCarols
  351.     repeat with i = 1 to count(soundChannels)
  352.       set theChannel to getAt(soundChannels, i)
  353.       if getProp(theChannel, #sndName) = whichSound then
  354.         if soundBusy(i) then
  355.           exit
  356.         end if
  357.       end if
  358.     end repeat
  359.   end repeat
  360.   set newSong to getAt(lsCarols, 1)
  361.   startSound(newSong)
  362.   set nextSong to getLast(lsCarols)
  363.   setState(oStoryteller, #windSongs, nextSong)
  364.   set gLastCarolStart to the ticks
  365. end
  366.  
  367. on killSongs optionSwitch
  368.   global oStoryteller, gSoundsSuspended, gCPU
  369.   if gSoundsSuspended then
  370.     exit
  371.   end if
  372.   if (optionSwitch = #PConly) and (gCPU <> #PC) then
  373.     exit
  374.   end if
  375.   set lsCarols to getProp(the lsStateData of oStoryteller, #windSongs)
  376.   set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
  377.   repeat with whichSound in lsCarols
  378.     repeat with i = 1 to count(soundChannels)
  379.       set theChannel to getAt(soundChannels, i)
  380.       if getProp(theChannel, #sndName) = whichSound then
  381.         if soundBusy(i) then
  382.           repeat with fadeFactor = 30.0 down to 10.0
  383.             set the volume of sound i to float(the volume of sound i) * (fadeFactor / 30.0)
  384.             wait(4)
  385.             updateStage()
  386.           end repeat
  387.           set the volume of sound i to 0
  388.           puppetSound(i, 0)
  389.           sound stop i
  390.           exit repeat
  391.         end if
  392.       end if
  393.     end repeat
  394.   end repeat
  395. end
  396.  
  397. on killSound whichSound
  398.   global oStoryteller
  399.   set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
  400.   repeat with i = 1 to count(soundChannels)
  401.     set theChannel to getAt(soundChannels, i)
  402.     if getProp(theChannel, #sndName) = whichSound then
  403.       if soundBusy(i) then
  404.         repeat with fadeFactor = 30.0 down to 10.0
  405.           set the volume of sound i to float(the volume of sound i) * (fadeFactor / 30.0)
  406.           wait(4)
  407.           updateStage()
  408.         end repeat
  409.         set the volume of sound i to 0
  410.         puppetSound(i, 0)
  411.         sound stop i
  412.         exit repeat
  413.       end if
  414.     end if
  415.   end repeat
  416. end
  417.  
  418. on pushQT startTime, stopTime, ticksPerFrame
  419.   set QTsprite to 44
  420.   set totalTime to stopTime - startTime
  421.   set the movieTime of sprite 44 to startTime
  422.   startTimer()
  423.   repeat while the timer <= totalTime
  424.     set the movieTime of sprite 44 to startTime + the timer
  425.     updateStage()
  426.   end repeat
  427.   set the movieTime of sprite 44 to stopTime
  428.   updateStage()
  429. end
  430.  
  431. on prerollQT startTime, stopTime, ticksPerFrame
  432.   set QTsprite to 44
  433.   set OnStage to the loc of sprite QTsprite
  434.   set the loc of sprite QTsprite to point(-10, -10)
  435.   set mTime to startTime
  436.   set the movieTime of sprite QTsprite to mTime
  437.   repeat while mTime < stopTime
  438.     set mTime to mTime + ticksPerFrame
  439.     set the movieTime of sprite QTsprite to mTime
  440.   end repeat
  441.   set the loc of sprite QTsprite to OnStage
  442.   set the visible of sprite QTsprite to 1
  443. end
  444.  
  445. on enableSongs
  446.   global oStoryteller
  447.   setState(oStoryteller, #carolsEnabled, 1)
  448. end
  449.  
  450. on disableSongs
  451.   global oStoryteller
  452.   setState(oStoryteller, #carolsEnabled, 0)
  453.   killSongs()
  454. end
  455.